using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.DirectX.Direct3D;

using SharpWind.Resources;
using System.Drawing;

using Mesh=SharpWind.Resources.Mesh;

namespace SharpWind.Scene
{
	public class SceneObject : SceneNode
	{
		private Mesh mesh = null;

		private Shader shader = null;

		private Color color  = Color.Red;
	
		public override void Render()
		{
			//if( this.shader.IsLost )
			//{
			//	this.shader = Engine.Instance.Content.Shaders[this.shader.Name];
			//}

			//Engine.Instance.Renderer.Device.VertexDeclaration =
				//new VertexDeclaration( Engine.Instance.Renderer.Device, this.mesh.D3DMesh.Declaration );

			this.shader.SetConstant( "worldViewProjection", Engine.Instance.Renderer.WorldViewProjection );
			this.shader.SetConstant( "color", this.color );

			int numPass = this.shader.Begin();

			for( int i = 0; i < numPass; i++ )
			{
				this.shader.BeginPass( i );
				this.mesh.Render();
				this.shader.EndPass();
			}
		}

		public Mesh Mesh
		{
			get
			{
				return this.mesh;
			}
			set
			{
				this.mesh = value;
			}
		}

		public Shader Shader
		{
			get
			{
				return this.shader;
			}
			set
			{
				this.shader = value;
			}
		}

		public Color Color
		{
			get
			{
				return this.color;
			}
			set
			{
				this.color = value;
			}
		}
	}
}
